package com.example.finance_manager.pages;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;

import com.example.finance_manager.R;
import com.example.finance_manager.dao.FlagDao;
import com.example.finance_manager.models.Flag;

import java.util.ArrayList;
import java.util.List;

public class FlagActivity extends AppCompatActivity {

    private ListView lvFlag;
    private List<Flag> flags;
    private ArrayList<String> datas;
    private ArrayAdapter<String> adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flag);

        lvFlag = findViewById(R.id.lv_my_flag);
        initData();

        adapter = new ArrayAdapter<>(this, R.layout.item_flag, datas);
        lvFlag.setAdapter(adapter);
    }

    private void initData() {
        FlagDao flagDao = new FlagDao(this);
        flags = flagDao.findAll();
        datas = new ArrayList<>();
        for (Flag flag : flags) {
            datas.add(flag.getContain());
        }
    }
}